<?php


namespace App\Models\Api;
use App\Models\CarModels\User;
use App\Models\SystemManagement\Employee;
use Illuminate\Database\Eloquent\Model;

class Files extends Model
{
    protected $table = 'file_upload';
    protected $fillable = ['local_server','remote_server','tx_server','ali_server','qiniu_server','type','user_id','upload_user_type'];

    function getLocalUrlAttribute($value){
        return $this->attributes['local_url'] = $_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].'/storage/'.$value;
    }

    function test()
    {
        return $this->hasOne(Files::class)->groupBy('type');
    }

    function upload_user()
    {
        return $this->belongsTo(Employee::class,'user_id');
    }
}